<div id="container">
<?php if (!$this->allow()) : ?>
	<div class="grid_12 t_a_bottom">
		<?php echo $this->translator->translator('Member_Access_deny_desc'); ?>
	</div>
<?php else : ?>

<?php
$version = Zend_Registry::get('version');
echo $this->headScript()->setFile($this->baseUrl().'/js/jquery/jquery.scrollTo-min.js');
?>

<script type="text/javascript">

$(document).ready(function() {	
	
	floatingbar('#floatingbar',"#button_top_bar",null);
	
	/**********Scrolling Tools Start****************/
	$.easing.elasout = function(x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	};
	
	$('#toc a').click(function(){//$.scrollTo works EXACTLY the same way, but scrolls the whole screen
		$.scrollTo( this.hash, 1500, { easing:'swing' });
		$(this.hash).find('span.message').text( this.title );
		return false;
	});
	
	$('span.top-go a').click(function(){//$.scrollTo works EXACTLY the same way, but scrolls the whole screen
		$.scrollTo( this.hash, 1500, { easing:'swing' });		
		return false;
	});
	
	/**********Scrolling Tools END****************/
	
	function stripslashes(str) 
	{
		str=str.replace(/\\'/g,'\'');
		str=str.replace(/\\"/g,'"');
		str=str.replace(/\\0/g,'\0');
		str=str.replace(/\\\\/g,'\\');
		return str;
	}
	
	
	function openMsgDialog(msg)
	{
		$('#dialog_msg').html(msg).dialog({
			autoOpen: true,
			modal: true,
			show: 'fade',
			resizable: 'false',				
			buttons: { "<?php echo html_entity_decode($this->translator->translator('common_ok'), ENT_QUOTES, 'UTF-8'); ?>": function() { $(this).dialog('option', 'hide', 'explode').dialog("close"); } },
			open: function(event, ui)
				 {
					setTimeout(function() 
					{									
						if($('#' + event.target.id).dialog('isOpen'))
						{
							$('#' + event.target.id).dialog('option', 'hide', 'explode').dialog('close');										
						}
					}, 10000);
				  }
		});
	}
		
	$('a.close_dialog_btn').click(function() {		 
		$("#upload-form").dialog('option','hide','explode').dialog('close');			
	});
		
	$('a.reset_btn').click(function() {			
		 resetFields();	
		 removeError();	
	});
	
	function resetFields()
	{
		$( "form" )[ 0 ].reset();					
	}
	
	function removeError()
	{
		$('#actionMessage').html('');
		
		var filename = '';
		var filevalue = '';		
		$.each($('form').serializeArray(), function(i, field) {	
				if(field.name.match(/\[\]$/))
				{
					var filearr = field.name.split('[]');
					filename = filearr[0];					
				}
				else
				{
					filename 	= 	field.name;
				} 			
				$('#'+filename).removeClass('ui-state-error');
				$('#'+filename+'_err').html('');									
		});				
	}
	
	function addError(key,errMsg)
	{
		var err_id = key+'_err';
		var field_name = key;
		$('#'+field_name).addClass('ui-state-error');
		$('#'+err_id).append(errMsg);
	}
	
	function openLoaderDialog()
	{
		$('#dialog_container').dialog({
			autoOpen: true,
			modal: true,
			show: 'fade',
			resizable: 'false',				
			open: function(event, ui)
				 {
					$("#progressbar").progressbar({
						value:100
		
					});							
				  }
		});
	}
	
	function closeLoaderDialog()
	{
		$('#dialog_container').dialog('option','hide','explode').dialog('close');
	}
	
	function getFormData()
	{
		var fieldObj = {};
		var filename = '';
		var filevalue = '';
		$.each($('form').serializeArray(), function(i, field) {	
			if(field.name.match(/\[\]$/))
			{
				var filearr = field.name.split('[]');
				filename = filearr[0];
				filevalue = $('#'+filename).val();
			}
			else
			{
				filename 	= 	field.name;
				filevalue 	= 	field.value;
			}			
			fieldObj[filename] = filevalue;			
		});
		return fieldObj;
	}
	
	$('a.add_new_btn').click(function() {			
			
		var formData = getFormData();
		
		$.ajax({
			url: "<?php echo $this->url( array('module' => 'Review','controller' => 'backend', 'action'     => 'new' ), 'adminrout',    true) ?>",
			  	type: 'POST',
			  	data: formData,
				beforeSend: function(){						
						removeError();
						openLoaderDialog();				
					 },
				success: function(response){
					//alert(response);					
					var json_arr = eval("("+response+")");					
					closeLoaderDialog();					
					if(json_arr.status == 'ok')
					{
						$('#actionMessage').html(succMsgDesign(json_arr.msg));
						resetFields();									
					}
					else if(json_arr.status == 'errV')
					{
						$('#actionMessage').html(errMsgDesign("<?php echo $this->translator->translator('common_err'); ?>"));
												
						for(var i= 0; i < json_arr.msg.length; i++)
						{
							addError(json_arr.msg[i].key,json_arr.msg[i].value);							
						}
					}
					else
					{						
						$('#actionMessage').html(errMsgDesign(json_arr.msg));
					}
				},
				error: function(xhr, status, error){
					closeLoaderDialog();
					var msg = "Error! " + xhr.status + " " + error;
					$('#actionMessage').html(errMsgDesign(msg));
				}
		});
	});		
	
});
</script>

<div class="title-container" id="topGo">
	<div class="reviews-group-add"><h1><?php echo $this->translator->translator('review_new_page_name'); ?></h1></div>
    
    <div class="button-container">
        <span class="button  ui-widget-content-1"><a href="<?php echo $this->url( array('module' => 'Review','controller' => 'backend', 'action'     => 'group' ), 'adminrout',    true) ?>" class="back_btn_link"><span class="icon back"><?php echo $this->translator->translator('common_back'); ?></span></a></span>
        <span class="button  ui-widget-content-1"><a href="javascript:  void(0);" class="reset_btn"><span class="icon reset"><?php echo $this->translator->translator('common_reset'); ?></span></a></span>
        <span class="button  ui-widget-content-1"><a href="javascript: void(0);" class="add_new_btn"><span class="icon save"><?php echo $this->translator->translator('common_save'); ?></span></a></span>
    </div>
</div>

<div class="content-container" id="button_top_bar">
    <form name="formSettings" id="formSettings" method="post">
    	<div id="actionMessage"></div>
        	<div id="generalInfo">
        	<fieldset class="fieldset">
            	<legend class="legend"><?php echo $this->translator->translator('review_setting_page_info'); ?></legend>
                <div class="form">
                	<?php
						$elements = $this->settingForm->getElements();
						foreach($elements as $element)
						{
					?>
                    <div class="form-row">
                        <div class="label">
                            <?php echo $element->getLabel();  if($element->isRequired()){ ?><span class="required">*</span><?php } ?>
                        </div>
                        
                        <div class="field">
                           	<?php
								if( $element->getType() == 'Zend_Form_Element_Hidden')
								{ 
							?>	
                            	<span class="button ui-widget-content-1"><a href="javascript:  void(0);" class="upload_btn"><span class="icon upload"><?php echo $this->translator->translator('common_upload'); ?></span></a></span>
                                <?php echo $element; ?>&nbsp;&nbsp;<span id="selected_file"></span>
                                <div class="ui-widget ui-helper-clearfix info"><div class="ui-widget-header ui-corner-all" title="<?php echo $this->escape($element->getAttrib('title')); ?>"><p><span class="ui-icon ui-icon-info"></span></p></div></div>
                                <div class="input-errors" id="<?php echo $element->getName().'_err'; ?>"></div>
							<?php
                                }
                                else
                                {	
                           	?>
                             	<?php echo $element; ?>
                                <div class="ui-widget ui-helper-clearfix info"><div class="ui-widget-header ui-corner-all" title="<?php echo $this->escape($element->getAttrib('title')); ?>"><p><span class="ui-icon ui-icon-info"></span></p></div></div>
                                <div class="input-errors" id="<?php echo $element->getName().'_err'; ?>"></div>
                          	<?php
                               }
                          	?>
                        </div>
                    </div>
                    <?php
						}
					?>
                </div>
                <span class="top-go right-float"><a href="#topGo"><img src="application/modules/Administrator/layouts/scripts/images/tools/top.png" border="0" alt="<?php echo $this->translator->translator('common_go_top_title'); ?>" title="<?php echo $this->translator->translator('common_go_top_title'); ?>" /></a></span>
			</fieldset>  
        </div>
	</form>
    <div class="button-container">
        <span class="button  ui-widget-content-1"><a href="<?php echo $this->url( array('module' => 'Review','controller' => 'backend', 'action'     => 'group' ), 'adminrout',    true) ?>" class="back_btn_link"><span class="icon back"><?php echo $this->translator->translator('common_back'); ?></span></a></span>
        <span class="button  ui-widget-content-1"><a href="javascript:  void(0);" class="reset_btn"><span class="icon reset"><?php echo $this->translator->translator('common_reset'); ?></span></a></span>
        <span class="button  ui-widget-content-1"><a href="javascript: void(0);" class="add_new_btn"><span class="icon save"><?php echo $this->translator->translator('common_save'); ?></span></a></span>
    </div>
</div>

<div id="dialog_msg" title="<?php echo $this->translator->translator('common_dialog_msg',$this->translator->translator('review_new_page_name')); ?>"></div>
<div id="dialog_container" style="display:none" title="<?php echo $this->translator->translator('common_processing_language'); ?>">
	<div id="progressbar" ></div>	
</div>

<div id="floatingbar">
	<h1><?php echo $this->translator->translator('review_new_page_name'); ?></h1>
    
    <div class="button-container">
        <span class="button  ui-widget-content-1"><a href="<?php echo $this->url( array('module' => 'Review','controller' => 'backend', 'action'     => 'group' ), 'adminrout',    true) ?>" class="back_btn_link"><span class="icon back"><?php echo $this->translator->translator('common_back'); ?></span></a></span>
        <span class="button  ui-widget-content-1"><a href="javascript:  void(0);" class="reset_btn"><span class="icon reset"><?php echo $this->translator->translator('common_reset'); ?></span></a></span>
        <span class="button  ui-widget-content-1"><a href="javascript: void(0);" class="add_new_btn"><span class="icon save"><?php echo $this->translator->translator('common_save'); ?></span></a></span>
    </div>
</div>
<?php endif; ?>	
</div>